// 骑手位置
const basePage = require('../../common/BasePage')
Page({
  behaviors: [basePage],

  /**
   * 页面的初始数据
   */
  data: {
    driver: {
      distance: 10,
      driverLastLoc: "113.71776,34.767501",
      driverMobile: "13544304212",
      driverName: "xxx",
      expectedArriveTime: "2024-09-01 16:55:55",
      orderCode: "sn123454"
    },
    latitude: 34.767501,
    longitude: 113.71776,
    markers: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    console.log('options', options);
    let markers = [];
    if (options.lat && options.lng) {
      markers.push({
        id: 2,
        latitude: options.lat,
        longitude: options.lng,
        iconPath: '/assets/shou1.png',
        width: 68,
        height: 68,
        customCallout: {
          anchorY: 34,
          anchorX: 34,
          display: 'ALWAYS',
        },
      })
    }
    this.request({
      url: this.data.host + '/v1/orders/uu-order/' + options.sn,
    }, res => {
      console.log('uu', res);
      let arr = res.data.driverLastLoc.split(",");
      markers.push({
        id: 1,
        latitude: arr[1],
        longitude: arr[0],
        iconPath: '/assets/qs.png',
        width: 64,
        height: 52,
        customCallout: {
          anchorY: 0,
          anchorX: 20,
          display: 'ALWAYS',
        },
      })
      // arr.push()
      this.setData({
        driver: res.data,
        latitude: arr[1],
        longitude: arr[0],
        markers: markers
      })
    })
  },
  tel_click() {
    wx.makePhoneCall({
      phoneNumber: this.data.driver.driverMobile,
      success: (res) => {},
      fail: (res) => {},
      complete: (res) => {},
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})